<#cenluan title="编辑相册" validate="true">
	<ol class="breadcrumb">
		<li><a href="/gallery">相册</a></li>
		<li><a href="/gallery/show/${gallery.id}">详情</a></li>
		<li class="active">编辑信息</li>
	</ol>
	<form action="/gallery/update" class="form-horizontal" method="post">
		<input type="hidden" name="gallery.id" value="${gallery.id}">
		<div class="form-group">
			<label class="control-label col-md-2">创建时间</label>
			<div class="col-md-5">
				<p class="form-control-static">
					${gallery.createTime,"yyyy-MM-dd HH:mm:ss"}
					<span class="text-success">（${gallery.createTime,prettyTime}）</span>
				</p>
			</div>
		</div>
				<div class="form-group">
					<label class="control-label col-md-2">标题</label>
					<div class="col-md-5">
						<input type="text" class="form-control" name="gallery.title"
						 minlength="2" maxlength="32" required placeholder="3-32个字" value="${gallery.title}"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-md-2">密码</label>
					<div class="col-md-5">
						<input type="text" class="form-control" name="gallery.pwd" value="${gallery.pwd!}" 
						maxlength="6" minlength="6" placeholder="6位数字"/>
					</div>
				</div>
				<div class="form-group">
					<label class="control-label col-md-2">简介</label>
					<div class="col-md-5">
						<textarea style="resize:vertical" class="form-control" name="gallery.intro"
						maxlength="500" placeholder="500字以内">${gallery.intro!}</textarea>
					</div>
				</div>
				<div class="form-group">
					<div class="col-md-3 col-md-offset-2">
						<button class="btn btn-primary btn-block" type="submit">
							提交&nbsp;<span class="glyphicon glyphicon-ok"></span>
						</button>
					</div>
				</div>
				
	</form>
	<script>
		$(function() {
			$("form").validate({
				rules : {
					"gallery.pwd" : {
						digits : true
					}
				},
				submitHandler : function(form) {
					$(form).find(":submit").button("loading");
					$(form).ajaxSubmit(function(json) {
						$(form).find(":submit").button("reset");
						var msg = null;
						if (json.ok) {
							msg = $("<div class='alert alert-success text-center'>保存成功</div>");
						} else {
							msg = $("<div class='alert alert-danger text-center'>" + json.msg + "</div>")
						}
						$(form).before(msg);
						setTimeout(function() {
							msg.remove();
						}, 2000);
					});
				}
			});
		});
	</script>
</#cenluan>